<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet SYSTEM "lang://users">

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	
	
	<xsl:include href="../main.xsl" />
	<xsl:include href="menu.xsl" />
	<xsl:include href="../common/form.xsl" />

	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/user-profile.css" type="text/css" media="all" />
			<link rel="stylesheet" href="{$baseURI}/css/forms.css" type="text/css" media="all" />
			<script type="text/javascript" src="{$baseURI}/js/simpleEditor.js" />
		</head>
		<body>
			
			<xsl:call-template name="top-userbar" />

			<div id="header">
				<xsl:call-template name="logo" />

				<xsl:call-template name="menu" />
			</div>

			<div id="blocks">
				<div id="blocks_inner">
					<xsl:call-template name="default-blocks-top" />
				</div>
			</div>

			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="response" />
				</div>
			</div>

			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="response">
		<h1>&labelEditProfile;</h1>
		
		<div id="small_menu">
			<a href="{$baseURI}/users/edit_profile" class="selected">&labelEditPersonal;</a>
			<a href="{$baseURI}/users/avatars_manager">&labelAvatars;</a>
			<a href="{$baseURI}/users/site_settings">&labelEditSite;</a>
			<a href="{$baseURI}/users/change_password">&labelChangePass;</a>
			<a href="{$baseURI}/users/delete_profile">&labelDeleteProfile;</a>
		</div>
		
		<xsl:apply-templates select="message" />
		
		<form action="{$baseURI}/users/edit_profile/save" method="post" enctype="multipart/form-data">
			<xsl:apply-templates select="form" />
			<p>
				<input type="submit" value="&labelSaveSettings;" />		
			</p>
		</form>
	</xsl:template>
	
	<xsl:template match="form/field[@name='login' and @character='latin']" />
	<xsl:template match="form/field[@name='group' and @character='integer']" />
	
	<xsl:template match="form/field[@name='birthdate' and @character='birthdate']">
		<xsl:param name="birthdate" select="document(concat('xmodule://users/getEditBirthdate/', ../@prefix))/data/response/birthdate" />
		
		<div class="form_field">
			<div class="form_field_label"><xsl:value-of select="title" />:</div>
			<div class="form_field_input">
				<select name="birthdate_day">
					<option value="">- &labelDay;</option>
					<xsl:for-each select="$birthdate/days/day">
						<option>
							<xsl:if test="selected = '1'">
								<xsl:attribute name="selected">selected</xsl:attribute>
							</xsl:if>
							<xsl:value-of select="value" />
						</option>
					</xsl:for-each>
				</select>
				<xsl:text> </xsl:text>
				<select name="birthdate_month">
					<option value="">- &labelMonth;</option>
					<xsl:for-each select="$birthdate/months/month">
						<option>
							<xsl:if test="selected = '1'">
								<xsl:attribute name="selected">selected</xsl:attribute>
							</xsl:if>
							<xsl:attribute name="value">
								<xsl:value-of select="value" />
							</xsl:attribute>
							<xsl:value-of select="title" />
						</option>
					</xsl:for-each>
				</select>
				<xsl:text> </xsl:text>
				<select name="birthdate_year">
					<option value="">- &labelYear;</option>
					<xsl:for-each select="$birthdate/years/year">
						<option>
							<xsl:if test="selected = '1'">
								<xsl:attribute name="selected">selected</xsl:attribute>
							</xsl:if>
							<xsl:value-of select="value" />
						</option>
					</xsl:for-each>
				</select>
				
				<xsl:if test="error != ''">
					<br /><span class="form_field_error"><xsl:value-of select="error" /></span>
				</xsl:if>
				<xsl:if test="help != ''">
					<br /><span class="form_field_help"><xsl:value-of select="help" /></span>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template match="form/field[@name='gender' and @character='latin']">
		<div class="form_field">
			<div class="form_field_label">
				<label for="field_{@id}">
					<xsl:value-of select="title" />
					<xsl:text>:</xsl:text>
				</label>
			</div>
			<div class="form_field_input">
				<select id="field_{@id}" class="form_input_select" name="data[{$formPrefix}][{@name}]">					
					<option value="man">
						<xsl:if test="value = 'man'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>&labelMan;</xsl:text>
					</option>
					<option value="woman">
						<xsl:if test="value = 'woman'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>&labelWoman;</xsl:text>
					</option>
					<option value="other">
						<xsl:if test="value = 'other'">
							<xsl:attribute name="selected"><xsl:text>selected</xsl:text></xsl:attribute>
						</xsl:if>
						<xsl:text>&labelNoGender;</xsl:text>
					</option>
				</select>
				<xsl:if test="error != ''">
					<br /><span class="form_field_error"><xsl:value-of select="error" /></span>
				</xsl:if>
				<xsl:if test="help != ''">
					<br /><span class="form_field_help"><xsl:value-of select="help" /></span>
				</xsl:if>
			</div>
		</div>
	</xsl:template>
	
</xsl:stylesheet>